package com.tw.ddd.trainning.umlhomework.parking;

import lombok.Builder;
import lombok.Data;

import java.util.Map;

@Builder
@Data
public class ParkingLot {
    String id;
    int capacity;
    Map<Ticket, Car> parkedCars;

    Ticket park(Car car) {
        return null;
    }

    Car take(Ticket ticket) {
        return null;
    }

    boolean isAvailable() {
        if (capacity <= 0)
            return false;
        if (parkedCars == null) {
            return true;
        }
        return capacity > parkedCars.size();
    }

    int getAvailableNumber() {
        if (isAvailable()) {
            return parkedCars == null ? capacity : capacity - parkedCars.size();
        } else {
            return 0;
        }
    }
}
